/**
 * 
 */
package huajiu.com.base;

import java.io.InputStream;

import com.sun.mail.util.BASE64EncoderStream;

/**
 * @author ItBotPjq
 *2018年2月9日
 */
public class Base64 {
	public static String encode(InputStream in) {
		try {
			byte[] bytes = BASE64EncoderStream.encode(FileUtil.readAsBytes(in));
			return new String(bytes);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
	public static String encode(String path) {
		try {
			byte[] bytes = BASE64EncoderStream.encode(FileUtil.readAsBytes(path));
			return new String(bytes);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}


}
